package cn.tedu.test;

import java.util.Scanner;

public class PrimeNumber {
    public static void main(String[] args) {
        f1();

    }

    private static void f1() {



        try {
            getPrimeNumber();
        }catch (Exception e){
            System.out.println("输入有误,请重新输入");

        }

    }

    private static void getPrimeNumber()throws Exception {
        System.out.println("请输入要判断的自然数");
        int n=new Scanner(System.in).nextInt();
        if(n<2){
            System.out.println(n+"不是质数");
            return;
        }
        if(n==2){
            System.out.println(n+"是质数");
            return;
        }
        double max=1+Math.sqrt(n);
        for(int i=2;i<=max;i++){
            if(n%i==0){
                System.out.println(n+"不是质数");
                return;
            }
            System.out.println(n+"是质数");
        }
    }
}
